//
//  UIButton+Extension.swift
//  LRWeibo
//
//  Created by Ruihaha on 16/9/22.
//  Copyright © 2016年 macbook air . All rights reserved.
//

import UIKit

extension UIButton{

    convenience init(title:String="",imageName:String?,target:Any?, action:Selector?){
    
        self.init()
        self.setImage(UIImage(named: imageName!), for: .normal)
        self.setImage(UIImage(named: imageName! + "_highlighted"), for: .highlighted)
        self.setTitle(title, for: .normal)
        self.setTitleColor(UIColor.darkGray, for: .normal)
        self.setTitleColor(UIColor.orange, for: .highlighted)
        self.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        self.addTarget(target,action: (action)!, for: .touchUpInside)
        self.sizeToFit()
        
        if let tar = target ,
            let ac = action {
            self.addTarget(tar, action: ac, for: .touchUpInside)
            
        }

    
    }
    
    
}
